let temp1 = Array.from({length: 24}, (_, i) => (Math.random() * 10 + 5).toFixed(2))
let temp2 = Array.from({length: 24}, (_, i) => (Math.random() * -10 - 5).toFixed(2))

let agv1 = Array.from({length: 24}).fill((temp1.reduce((o, c) => {
    return o += parseFloat(c)
}, 0) / 24).toFixed(2))

let agv2 = Array.from({length: 24}).fill((temp2.reduce((o, c) => {
    return o += parseFloat(c)
}, 0) / 24).toFixed(2))

let times = Array.from({length: 24}, (_, i) => i + ':00')

const columns = [{prop: 'root_name', label: '房间'}].concat(times.map((title, i) => ({prop: `data${i}`, label: title})))


const option = {
    title: {
        text: 'L01-温湿度曲线图',
        left: 'center',
    },
    tooltip: {
        trigger: 'axis',
    },
    legend: {
        left: '2%',
        data: ['温度(C°)', '露点(C°)', '平均温度(C°)', '平均露点(C°)']
    },
    grid: {
        left: '2%',
        right: '2%',
        bottom: '3%',
        containLabel: true
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: times
    },
    yAxis: {
        type: 'value'
    },
    series: [
        {
            name: '温度(C°)',
            type: 'line',
            symbolSize: 0,
            itemStyle: {
                color: '#EE822F'
            },
            data: temp1
        },
        {
            name: '露点(C°)',
            type: 'line',
            symbolSize: 0,
            itemStyle: {
                color: '#F2BA02'
            },
            data: temp2
        },
        {
            name: '平均温度(C°)',
            type: 'line',
            symbolSize: 0,
            itemStyle: {
                color: '#75BD42'
            },
            data: agv1
        },
        {
            name: '平均露点(C°)',
            type: 'line',
            symbolSize: 0,
            itemStyle: {
                color: '#31C0B4'
            },
            data: agv2
        }
    ]
};


export {
    option,
    temp1,
    temp2,
    agv1,
    agv2,
    columns
}